﻿{extends file='main.tpl'}
{block name='title'}
	{if $context eq 'account_edit'}
		Modifier mon Compte
	{else}
		Créer mon Compte
	{/if}
{/block}
{block name='content'}

    <!-- Formulaire compte-->

		<form method="post" action="index.php?page=account_checker"  onsubmit="return validate()" >    
        <fieldset>
            <legend>Compte</legend>
            <!-- Adresse email -->
            <label class="labelAdressField">Adresse email :</label>
			{if $context eq 'account_edit'}
				<b>{$customer.mail}</b>
				<input type="hidden" name="mail" value="{$customer.mail}" />
			{else}
            <input name="mail" type="email" name="email" placeholder="ex: 'exemple@mail.com'" id="email" size="50" value="{$customer.mail}" />
			{/if}
            <span id="emailError" class="wrongValueMsg" ></span>
            <br />

            <!-- Mot de passe -->
            <label class="labelAdressField">Mot de passe :</label>

            <input type="password" name="password" id="password" size="50" />
            <span id="passwordError" class="wrongValueMsg" ></span>
            <br />

            <!-- Confirmation -->
            <label class="labelAdressField">Confirmation :</label>

            <input type="password" name="confirmation" id="confirmation" size="50" />
            <span id="confirmationError" class="wrongValueMsg" ></span>
            <br />
        </fieldset>

        <!-- Formulaire facturation-->
        <div class="accountEditLeftFieldset">
            <fieldset>
                <legend>Adresse de facturation</legend>

                <!-- Titre -->
                <label class="labelAdressField">Titre :</label>
                <input type="radio" name="title" value="Mr" {if {$customer.title} eq 'Mr'} checked="true" {/if}>Mr</input>
                <input type="radio" name="title" value="Mme" {if {$customer.title} eq 'Mme'} checked="true" {/if}>Mme</input>
				<span id="titleError" class="wrongValueMsg" ></span>
                <br />

                <!-- Prenom -->
                <label class="labelAdressField">Prénom :</label>

                <input type=text" name="firstname" placeholder="ex: 'Michel'" id="firstname" value="{$customer.firstname}"/>
                <span id="firstnameError" class="wrongValueMsg" ></span>
                <br />

                <!-- Nom -->
                <label class="labelAdressField">Nom :</label>

                <input type=text" name="name" placeholder="ex: 'Dupond'" id="name" value="{$customer.name}"/>
                <span id="nameError" class="wrongValueMsg" ></span>
                <br />

                <!-- Adresse -->
                <label class="labelAdressField">Adresse :</label>
                <input type="text" name="address" placeholder="ex: '12 rue du 22 novembre'" size="30" id="address" value="{$customer.address}"/>
                <span id="addressError" class="wrongValueMsg" ></span>
                <br />

                <!-- Code postal -->
                <label class="labelAdressField">Code postal :</label>

                <input type="number" name="postalCode" placeholder="ex: '67000'" id="postal" step="10" value="{$customer.postalCode}"/>
                <span id="postalError" class="wrongValueMsg" ></span>
                <br />

                <!-- Ville -->
                <label class="labelAdressField">Ville :</label>
                <input type="text" name="city" placeholder="ex: 'Strasbourg'" size="30" id="city" value="{$customer.city}" />
                <span id="cityError" class="wrongValueMsg" ></span>
                <br />

                <!-- Telephone -->
                <label class="labelAdressField">Téléphone :</label>

                <input type="tel" name="phone" placeholder="ex: '0123456789'" size="30" id="phone" value="{$customer.phone}"/>
                <span id="phoneError" class="wrongValueMsg" ></span>
                <br />


            </fieldset>
        </div>
        <div class="accountEditRightFieldset" >
            <!-- Formulaire livraison-->
            <fieldset id="deliveryForm">
                <legend>Adresse de livraison</legend>

                <!-- Genre -->
                <label class="labelAdressField">Titre :</label>
                <input type="radio" name="titleDelivery" value="Mr" {if $customerBis.titleDelivery eq 'Mr'} checked="true" {/if}>Mr</input>
                <input type="radio" name="titleDelivery" value="Mme" {if $customerBis.titleDelivery eq 'Mme'} checked="true" {/if}>Mme</input>
				<span id="titleError" class="wrongValueMsg" ></span>
                <br />

                <!-- Prenom -->
                <label class="labelAdressField">Prénom :</label>

                <input type=text" name="firstnameDelivery" placeholder="ex: 'Michel'" id="firstnameDelivery" value="{$customerBis.firstnameDelivery}"/>
                <span id="firstnameDeliveryError" class="wrongValueMsg" ></span>
                <br />

                <!-- Nom -->
                <label class="labelAdressField">Nom :</label>

                <input type=text" name="nameDelivery" placeholder="ex: 'Dupond'" id="nameDelivery"  value="{$customerBis.nameDelivery}"/>
                <span id="nameDeliveryError" class="wrongValueMsg" ></span>
                <br />

                <!-- Adresse -->
                <label class="labelAdressField">Adresse :</label>
                <input type="text" name="addressDelivery" placeholder="ex: '12 rue du 22 novembre'" size="30" id="addressDelivery" value="{$customerBis.addressDelivery}"/>
                <span id="addressDeliveryError" class="wrongValueMsg" ></span>
                <br />

                <!-- Code postal -->
                <label class="labelAdressField">Code postal :</label>

                <input type="number" name="postalCodeDelivery" placeholder="ex: '67000'" id="postalDelivery" step="10" value="{$customerBis.postalCodeDelivery}"/>
                <span id="postalDeliveryError" class="wrongValueMsg" ></span>
                <br />

                <!-- Ville -->
                <label class="labelAdressField">Ville :</label>
                <input type="text" name="cityDelivery" placeholder="ex: 'Strasbourg'" size="30" id="cityDelivery" value="{$customerBis.cityDelivery}"/>
                <span id="cityDeliveryError" class="wrongValueMsg" ></span>
                <br />

                <!-- Telephone -->
                <label class="labelAdressField">Téléphone :</label>

                <input type="tel" name="phoneDelivery" placeholder="ex: '0123456789'" size="30" id="phoneDelivery" value="{$customerBis.phoneDelivery}"/>
                <span id="phoneDeliveryError" class="wrongValueMsg" ></span>
                <br />

            </fieldset>
        </div>
        <br />
        <div class="editAcountButtons">
            <input type="checkbox" name="deliveryAdress" id="deliveryAdress" onchange="switchDeliveryForm();" {if $hasSecondAdress} checked="true" {else} checked="false" {/if}>
            <label for="deliveryAdress" >Livrer à l'adresse de facturation</label>
            <br />
            <input type="submit" value="Valider" />
            <input type="reset" value="Reset" onclick="return resetForm();"/>
			{if $context eq 'account_edit'}
				<input type="hidden" name="action" value="edit_account" />
			{else}
				<input type="hidden" name="action" value="create_account" />
			{/if}
            
        </div>

    </form>
    
    
    
{/block}

{block name='javascript'}
    <script type="text/javascript" src="pages/controller/js/account.js"></script>
	<script type="text/javascript">
		//JQuery main entry point
		$(document).ready(function() {
			{if $hasSecondAdress}switchDeliveryForm();{/if}
		});
    </script>
{/block}